cmake_minimum_required(VERSION 3.10)

if(TARGET "pplnn_static")
    return()
endif()

add_library(pplnn_static STATIC IMPORTED)

# --------------------------------------------------------------------------- #

get_filename_component(__PPLNN_PACKAGE_ROOTDIR__ "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
set(__PPLNN_LINK_LIBRARIES__ @PPLNN_BINARY_EXTERNAL_LINK_LIBRARIES@)

# --------------------------------------------------------------------------- #

# exported definitions

option(PPLNN_USE_X86 "" @PPLNN_USE_X86@)
option(PPLNN_USE_ARM "" @PPLNN_USE_ARM@)
option(PPLNN_USE_RISCV "" @PPLNN_USE_RISCV@)
option(PPLNN_USE_CUDA "" @PPLNN_USE_CUDA@)

option(PPLNN_ENABLE_ONNX_MODEL "" @PPLNN_ENABLE_ONNX_MODEL@)
option(PPLNN_ENABLE_PMX_MODEL "" @PPLNN_ENABLE_PMX_MODEL@)

set(PPLNN_VERSION_MAJOR @PPLNN_VERSION_MAJOR@)
set(PPLNN_VERSION_MINOR @PPLNN_VERSION_MINOR@)
set(PPLNN_VERSION_PATCH @PPLNN_VERSION_PATCH@)
set(PPLNN_COMMIT_STR "@PPLNN_COMMIT_STR@")

set(PPLNN_INCLUDE_DIRS "${__PPLNN_PACKAGE_ROOTDIR__}/include")
set(PPLNN_LINK_DIRS "${__PPLNN_PACKAGE_ROOTDIR__}/lib")
set(PPLNN_LIBRARIES "pplnn_static")

# --------------------------------------------------------------------------- #

if(NOT TARGET "pplcommon_static")
    include(${CMAKE_CURRENT_LIST_DIR}/pplcommon-config.cmake)
endif()
list(APPEND __PPLNN_LINK_LIBRARIES__ "pplcommon_static")

if(PPLNN_USE_X86)
    if(NOT TARGET "pplkernelx86_static")
        include(${CMAKE_CURRENT_LIST_DIR}/pplkernelx86-config.cmake)
    endif()
    list(APPEND __PPLNN_LINK_LIBRARIES__ "pplkernelx86_static")
endif()

if(PPLNN_USE_ARM)
    if(NOT TARGET "pplkernelarmserver_static")
        include(${CMAKE_CURRENT_LIST_DIR}/pplkernelarm-config.cmake)
    endif()
    list(APPEND __PPLNN_LINK_LIBRARIES__ "pplkernelarmserver_static")
endif()

if(PPLNN_USE_CUDA)
    if(NOT TARGET "pplkernelcuda_static")
        include(${CMAKE_CURRENT_LIST_DIR}/pplkernelcuda-config.cmake)
    endif()
    list(APPEND __PPLNN_LINK_LIBRARIES__ "pplkernelcuda_static")
endif()

if(PPLNN_USE_RISCV)
    if(NOT TARGET "pplkernelriscv_static")
        include(${CMAKE_CURRENT_LIST_DIR}/pplkernelriscv-config.cmake)
    endif()
    list(APPEND __PPLNN_LINK_LIBRARIES__ "pplkernelriscv_static")
endif()

if(PPLNN_ENABLE_ONNX_MODEL)
    if(NOT TARGET "protobuf::libprotobuf")
        include(${__PPLNN_PACKAGE_ROOTDIR__}/lib/cmake/protobuf/protobuf-config.cmake)
    endif()
    list(APPEND __PPLNN_LINK_LIBRARIES__ "protobuf::libprotobuf")
endif()

# --------------------------------------------------------------------------- #

set_target_properties(pplnn_static PROPERTIES
    INTERFACE_LINK_LIBRARIES "${__PPLNN_LINK_LIBRARIES__}"
    IMPORTED_LOCATION "${__PPLNN_PACKAGE_ROOTDIR__}/lib/@__PPLNN_LIB_NAME__@"
    IMPORTED_LOCATION_DEBUG "${__PPLNN_PACKAGE_ROOTDIR__}/lib/@__PPLNN_LIB_NAME__@"
    IMPORTED_LOCATION_RELEASE "${__PPLNN_PACKAGE_ROOTDIR__}/lib/@__PPLNN_LIB_NAME__@")

# --------------------------------------------------------------------------- #

unset(__PPLNN_LINK_LIBRARIES__)
unset(__PPLNN_PACKAGE_ROOTDIR__)
